<template>
	<view>
		<!--header-->
		<view class="main-app modal-body">
			<view class="main-content en p-4">
				<form class="form-group login">

					<!-- <view>
						<view><label>{{$t('Counterparty_account')}}</label>
							<view class="mb-3 mt-1">
								<view>
									<view class="recharge_btn" style="padding-left: 20rpx;">{{userinfo.address}}</view>
								</view>
							</view>
						</view>
					</view> -->
					<view><label class="w-100">
							<view class="d-flex justify-content-between">
								<label>{{$t('UID_account')}}</label>
							</view>
						</label>
						<view class="mb-3 mt-1 undefined">
							<u--input :placeholder="input_account" border="none" v-model="codes" color="#fff"
								inputAlign="left" fontSize="14" class="recharge_btn"
								style="background:#556185;padding: 10rpx 24rpx;margin-bottom: 40rpx;"></u--input>


						</view>
					</view>
					<view><label class="w-100">
							<view class="d-flex justify-content-between"><label>{{$t('numbers')}}</label><span
									class="form-label-balance">{{$t('overall_rut_balance')}}:
									{{userinfo.coin}}</span>
							</view>
						</label>
						<view class="mb-3 mt-1 undefined">
							<u--input :placeholder="input_withdrawal" border="none" v-model="money" color="#fff"
								inputAlign="left" fontSize="14" class="recharge_btn"
								style="background:#556185;padding: 10rpx 24rpx;margin-bottom: 40rpx;"></u--input>


						</view>
					</view>
					<view style="margin-bottom: 10px; line-height: 12px;"><span
							style="color: rgb(193, 209, 255); font-size: 10px; opacity: 0.6;">{{$t('Transfer_note')}}:
						</span><br><span
							style="color: rgb(193, 209, 255); font-size: 10px; opacity: 0.6;">{{$t('Minimum_transfer_amount')}}:
							10 MTCC</span><br><span
							style="color: rgb(193, 209, 255); font-size: 10px; opacity: 0.6;">{{$t('Pay_by_transfer')}}:
							3%</span>
						<br><span
							style="color: rgb(193, 209, 255); font-size: 10px; opacity: 0.6;">{{$t('Only_the_relationship')}}
						</span>
					</view>
					<view><label>{{$t('Transaction_code')}}</label>
						<u--input :placeholder="input_your_password" border="none" v-model="password" color="#fff"
							type="password" inputAlign="left" fontSize="14" class="recharge_btn"
							style="background:#556185;padding: 10rpx 24rpx;margin-bottom: 40rpx;"></u--input>
					</view><span style="color: rgb(255, 97, 97); font-size: 10px; opacity: 0.6;"></span>
					<view class="profile-menu-container mt-4" style="padding-top: 40rpx;" @click="recharge">
						<view class="menu-card row" style="text-align: center; color: #000;">
							<u-button type="button" :loading="isLoading" :loadingText="loading" class="menu-card "
								disabled>{{$t('sure')}}</u-button>
						</view>
					</view>

				</form>
			</view>
		</view>
	</view>

</template>


<script>
	import topWallet from "@/components/nav/top_wallet.vue"
	export default {
		components: {
			topWallet,
		},
		onLoad: function(options) {
         
		},
		onShow() {
			this.tui.haslogin();
			if (this.tui.isLogin()) {
				this.init();
			}
		},
		data() {
			return {
				loading: this.$t('Load'),
				isLoading: false,
				money: "",
				userinfo: false,
				password: '',
				type:3,
				account: "",
				account_name: "",
				input_withdrawal: this.$t('enter_transfer_amount'),
				input_account: this.$t('enter_uid_account'),
				input_your_password: this.$t('input_your_password'),
				codes: '',
			}
		},
		methods: {
			recharge() {

				if (this.password == '') {
					this.tui.toast(this.input_your_password);
					return;
				}

				let token = this.tui.getToken();
				let datas = {
					token: token,
					amount: this.money,
					paypassword: this.password,
					type: this.type,
					codes: this.codes,
				};
				this.isLoading = true;
				let result = this.tui.request('/api/user/walletChange', 'post', datas, 1000, 1, '', 'walletChange');
				Promise.resolve(result).then((value) => {
					this.isLoading = false
					if (value.code == 200) {
						this.tui.toast(value.message);
						setTimeout(() => {
							this.isLoading = false;
							this.init()
						}, 1000);
						//写入缓存
					} else {
						this.isLoading = false
						this.tui.toast(value.message);
					}
				})
			},
			init() {
				console.log(11111)
				let result = this.tui.request('/api/user/userAccount', 'post', {}, 1000, 1, '', 'userAccount');
				Promise.resolve(result).then((value) => {
					if (value.code == 200) {
						this.userinfo = value.data;
						//写入缓存
					} else {
						this.tui.toast(value.message);
					}
				})

			},
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		onPullDownRefresh() {
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 200)
		},


	}
</script>

<style scoped lang="scss">
	.recharge_btn {
		background: rgba(193, 209, 255, .2) !important;
		border-right: none;
		border-bottom: none;
		border-radius: 15px;
		box-shadow: 0 4px 4px 0 rgba(0, 0, 0, .25);
		color: var(--Light-Blue-Solid) !important;
		font-size: 12px;
		height: 48px;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.u-button--disabled {
		opacity: 1;
	}
</style>